package com.principle.demeter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 冯志立
 * @create 2019-10-15 17:56
 */
public class Demeter {
    public static void main(String[] args) {
        SchoolManager schoolManager = new SchoolManager();
        schoolManager.printAllEmployee(new CollegeManager());
       schoolManager.hashCode();
    }
}

class Employee {
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}

class CollegeEmployee {
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}

class CollegeManager {
    public List<CollegeEmployee> getAllemployee() {
        List<CollegeEmployee> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            CollegeEmployee employee = new CollegeEmployee();
            employee.setId("学院ID=" + i);
            list.add(employee);
        }
        return list;
    }
}

class SchoolManager{
    public List<Employee> getAllEmployee(){
        ArrayList<Employee> list = new ArrayList<>();

        for (int i = 0; i < 5; i++) {
            Employee emp = new Employee();
            emp.setId("学校总部员工ID="+i);
            list.add(emp);
        }
        return list;
    }

    void printAllEmployee(CollegeManager sub){
        List<CollegeEmployee> list = sub.getAllemployee();
        System.out.println("--------分公司员工-------------------");
        for (CollegeEmployee e : list) {
            System.out.println(e.getId());
        }
        List<Employee> list1 = this.getAllEmployee();
        System.out.println("----------学校总部员工----------------");
        for (Employee e: list1) {
            System.out.println(e.getId());
        }
    }
}
